package com.kate.mall.bff.wx.feign;

import com.kate.mall.bff.wx.controller.form.CartAddForm;
import com.kate.mall.bff.wx.dto.OrderDTO;
import com.kate.mall.common.annotation.LoginUser;
import com.kate.mall.common.utils.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;

/**
 * @Description: 用一句话描述
 * @Auther: 新梦想*陈超
 * @Date: 2021/8/18 23:19
 */
@FeignClient(value = "order-center")
public interface OrderFeignClient {

    /*
    FeignException$UnsupportedMediaType异常
    consumes： 指定处理请求的提交内容类型（Content-Type），例如application/json, text/html;
      produces:    指定返回的内容类型，仅当request请求头中的(Accept)类型中包含该指定类型才返回；*/
    @PostMapping(value = "/order/order/save" ,consumes ="application/json" )
    R submit(@RequestBody String body);

    @GetMapping("/order/cart/list")
    R queryExist(@RequestParam("goods_id") Integer goodsId,
                 @RequestParam("product_id") Integer productId,
                 @RequestParam("price") BigDecimal price,
                 @RequestParam("user_id") Integer userId);
    @GetMapping("/order/cart/list")
    R queryByUidAndChecked(@RequestParam("user_id") Integer userId);

    @PostMapping("/order/cart/save")
    R add(@RequestBody CartAddForm cartAddForm);

    @PutMapping("/order/cart/update")
    R updateById(CartAddForm existCart);

    @GetMapping("/order/cart/list")
    R queryByUId(@RequestParam("user_id") Integer userId);

    @DeleteMapping("/order/cart/delete")
    void deleteById(@RequestBody Integer[] ids);

    @GetMapping("/order/cart/info/{id}")
    R findCartById(@PathVariable("id") Integer cartId);

    @PostMapping(value = "/order/order/prepay" ,consumes ="application/json" )
    R prepay(@RequestBody String body);

    @PostMapping("/order/order/price")
    R calculateOrderPrice(@RequestBody OrderDTO orderDTO);

    @PostMapping("/order/order/coupon")
    R calculateCouponPrice(@RequestBody OrderDTO orderDTO);

    @PostMapping("/order/order/save")
    R saveOrder(@RequestBody  OrderDTO orderDTO);

    @GetMapping("/order/order/groupon")
    R calculateGroupOnPrice( @RequestBody OrderDTO orderDTO);
}